package com.gz.im.backend.service.strategy;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author GuoZhong
 * @description 节点操作策略工厂
 * @date 2023/3/29 10:08
 */
@Component
@Slf4j
public class OperateStrategyFactory {
	private final Map<String, OperateStrategy> operateStrategyMap = new ConcurrentHashMap<>();

	public OperateStrategyFactory(Map<String, OperateStrategy> strategyMap) {
		this.operateStrategyMap.clear();
		strategyMap.forEach((k, v)-> this.operateStrategyMap.put(k, v));
	}

	/**
	 * 查找 具体实现类
	 * @param component
	 * @return
	 */
	public OperateStrategy getResource(String component){
		OperateStrategy operateStrategy = operateStrategyMap.get(component);
		return operateStrategy;
	}
}
